using OpenTK;
using OpenTK.Graphics.OpenGL;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace sm64
{
    

    public partial class EditorMainForm : Form
    {
        private ToolStripMenuItem btnAddObj0;
        private ToolStripMenuItem btnAddObj1;
        private ToolStripMenuItem btnAddObj2;
        private ToolStripMenuItem btnAddObj3;
        private ToolStripMenuItem btnAddObj4;
        private ToolStripMenuItem btnAddObj5;
        private ToolStripMenuItem btnAddObj6;
        private ToolStripMenuItem btnAddObj7;
        private ToolStripSplitButton btnAddObject;
        private ToolStripMenuItem btnDumpTexture;
        private ToolStripButton btnLayer0;
        private ToolStripButton btnLayer1;
        private ToolStripButton btnLayer2;
        private ToolStripButton btnLayer3;
        private ToolStripButton btnLayer4;
        private ToolStripButton btnLayer5;
        private ToolStripButton btnLayer6;
        private ToolStripButton btnLayer7;
        private ToolStripButton btnLevelSettings;
        private ToolStripButton btnRemoveObject;
        private ToolStripButton btnReverseRot;
        private ToolStripButton btnSaveLevel;
        private IContainer components;
        private ContextMenuStrip ctm3DOptions;
        private GLControl glc3DView;
        private uint m_BaseRAMAddr;
        private float m_CamDistance;
        private Matrix4 m_CamMatrix;
        private Vector3 m_CamPosition;
        private Vector2 m_CamRotation;
        private Vector3 m_CamTarget;
        private CClientStateCache m_CSCache;
        private int m_CurObjType;
        private List<EditorMainForm> m_EditorList;
        private bool m_GLLoaded;
        private Point m_LastMouseClick;
        private Point m_LastMouseMove;
        private uint m_LayerMask;
        private int m_LevelID;
        private CBMD m_LevelModel;
        private uint m_LevelOffset;
        private Point m_MouseCoords;
        private int m_MouseDown;
        private byte m_MyBackground;
        private List<IGLGeometry> m_OLevelGeometry;
        private List<IGLGeometry> m_OSkyboxGeometry;
        private uint[] m_PickingFrameBuffer;
        private float m_PixelFactorX;
        private float m_PixelFactorY;
        private uint m_Selection;
        private int m_SelObjType;
        private Matrix4 m_SkyboxMatrix;
        private CBMD m_SkyboxModel;
        private List<IGLGeometry> m_TLevelGeometry;
        private List<IGLGeometry> m_TSkyboxGeometry;
        private uint m_UnderCursor;
        private bool m_UpsideDown;
        private ToolStripStatusLabel sblStatusLabel;
        private StatusStrip sbrStatus;
        private SplitContainer scObjPanelContainer;
        private SplitContainer splitContainer1;
        private TabControl tbcLeftPanel;
        private TabControl tbcObjTypeTabs;
        private TabPage tbpModelBlox;
        private TabPage tbpObj0Panel;
        private TabPage tbpObj1Panel;
        private TabPage tbpObj2Panel;
        private TabPage tbpObjects;
        private SaveFileDialog texexport;
        private TableLayoutPanel tlpObjEditPanel;
        private ToolStrip toolStrip1;
        private ToolStrip toolStrip2;
        private TreeView tvModelBlocks;
        private TreeView tvObjectList;
        private byte[] bmd_2;
        public EditorMainForm(byte[] bmd_)
        {
            bmd_2 = bmd_;
            this.InitializeComponent();
            try
            {
                this.m_MouseDown = 0;
                this.m_GLLoaded = false;
                
                this.LoadLevelData();
                this.sblStatusLabel.Text = "Ready";
                this.m_CurObjType = 0;
                this.m_SelObjType = -1;
            }
            catch
            {
                base.Dispose(true);
            }
        }

        private EditorMainForm()
        {
            
            this.m_EditorList.Remove(this);
            if (this.components != null)
            {
                IDisposable components = this.components;
                if (components != null)
                {
                    components.Dispose();
                }
            }
        }

        
        private unsafe void btnDumpTexture_Click(object sender, EventArgs e)
        {
            CBMD.CMatPolyPair pair = null;
            CBMD.CModelChunk chunk = null;
            Image image = null;
            if ((this.tvModelBlocks.SelectedNode != null) && (this.tvModelBlocks.SelectedNode.Level == 1))
            {
                int index = this.tvModelBlocks.SelectedNode.Parent.Index;
                int num2 = this.tvModelBlocks.SelectedNode.Index;
                chunk = this.m_LevelModel.m_ModelChunks[index];
                pair = chunk.m_MatPolyPairs[num2];
                if (pair.m_Texture == null)
                {
                    this.sblStatusLabel.Text = string.Format("'{0}/{1}' has no texture associated.", chunk.m_Name, pair.m_Name);
                }
                else
                {
                    this.texexport.Title = string.Format("Save texture '{0}' from '{1}/{2}'", pair.m_TexName, chunk.m_Name, pair.m_Name);
                    this.texexport.FileName = pair.m_TexName + ".png";
                    if (this.texexport.ShowDialog(this) == DialogResult.OK)
                    {
                   
                      
                 
                        

                        image.Save(this.texexport.FileName, ImageFormat.Png);
                        IDisposable disposable = image;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                        
                        this.sblStatusLabel.Text = string.Format("Texture from '{0}/{1}' successfully saved.", chunk.m_Name, pair.m_Name);
                    }
                }
            }
        }

        


        private void BuildGeometry()
        {
 
            this.m_OSkyboxGeometry = new List<IGLGeometry>();
            this.m_TSkyboxGeometry = new List<IGLGeometry>();
            this.m_OLevelGeometry = new List<IGLGeometry>();
            this.m_TLevelGeometry = new List<IGLGeometry>();
            this.BuildSkyboxGeometry();
            this.BuildLevelGeometry();
            

            
            GL.LineWidth(2f);
            GL.PointSize(5f);
        }

        private void BuildLevelGeometry()
        {
            IGLGeometry item = null;
            CBMD.CModelChunk chunk = null;
            CBMD.CMatPolyPair mppair = null;
            int length = this.m_LevelModel.m_ModelChunks.Length;
            float scaleFactor = this.m_LevelModel.m_ScaleFactor;
            int index = 0;
        Label_002C:
            if (index >= length)
            {
                return;
            }
            chunk = this.m_LevelModel.m_ModelChunks[index];
            int num3 = chunk.m_MatPolyPairs.Length;
            this.tvModelBlocks.Nodes.Insert(index, string.Format("[{0}] {1}", chunk.m_ID, chunk.m_Name));
            this.tvModelBlocks.Nodes[index].Checked = true;
            int num2 = 0;
            while (true)
            {
                if (num2 >= num3)
                {
                    index++;
                    goto Label_002C;
                }
                mppair = chunk.m_MatPolyPairs[num2];
                item = new CGLG_BMDPart(scaleFactor, mppair);
                this.tvModelBlocks.Nodes[index].Nodes.Insert(num2, string.Format("[{0}] {1}", mppair.m_ID, mppair.m_Name));
                this.tvModelBlocks.Nodes[index].Nodes[num2].Tag = item;
                this.tvModelBlocks.Nodes[index].Nodes[num2].Checked = true;
                if (item.IsTranslucent())
                {
                    this.m_TLevelGeometry.Add(item);
                }
                else
                {
                    this.m_OLevelGeometry.Add(item);
                }
                num2++;
            }
        }

        private void BuildSkyboxGeometry()
        {
            IGLGeometry item = null;
            CBMD.CModelChunk chunk = null;
            CBMD.CMatPolyPair mppair = null;
            IGLGeometry geometry2 = null;
            IGLGeometry current = null;
            List<IGLGeometry>.Enumerator enumerator2 = this.m_OSkyboxGeometry.GetEnumerator();
            while (true)
            {
                if (!enumerator2.MoveNext())
                {
                    break;
                }
                current = enumerator2.Current;
                IDisposable disposable2 = current as IDisposable;
                if (disposable2 != null)
                {
                    disposable2.Dispose();
                }
            }
            List<IGLGeometry>.Enumerator enumerator = this.m_TSkyboxGeometry.GetEnumerator();
            while (true)
            {
                if (!enumerator.MoveNext())
                {
                    break;
                }
                geometry2 = enumerator.Current;
                IDisposable disposable = geometry2 as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            this.m_OSkyboxGeometry.Clear();
            this.m_TSkyboxGeometry.Clear();
            if (this.m_SkyboxModel == null)
            {
                return;
            }
            int length = this.m_SkyboxModel.m_ModelChunks.Length;
            float scale = (float) (((double) this.m_SkyboxModel.m_ScaleFactor) / 75.0);
            int index = 0;
        Label_00DB:
            if (index >= length)
            {
                return;
            }
            chunk = this.m_SkyboxModel.m_ModelChunks[index];
            int num3 = chunk.m_MatPolyPairs.Length;
            int num = 0;
            while (true)
            {
                if (num >= num3)
                {
                    index++;
                    goto Label_00DB;
                }
                mppair = chunk.m_MatPolyPairs[num];
                item = new CGLG_BMDPart(scale, mppair);
                item.Toggle(true);
                if (item.IsTranslucent())
                {
                    this.m_TSkyboxGeometry.Add(item);
                }
                else
                {
                    this.m_OSkyboxGeometry.Add(item);
                }
                num++;
            }
        }

        

       

       

        private void EditorMainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
        }

        private void EditorMainForm_Paint(object sender, PaintEventArgs e)
        {
            
        }

       

        public int GetLevelID()
        {
            return this.m_LevelID;
        }

        private void glc3DView_KeyDown(object sender, KeyEventArgs e)
        {
            if ((this.m_Selection >> 0x1c) != 15)
            {
                float num = 0f;
                float num2 = 0f;
                bool flag = false;
                if ((e.KeyCode == Keys.D) || (e.KeyCode == Keys.NumPad6))
                {
                    num = 5f;
                }
                else if ((e.KeyCode == Keys.A) || (e.KeyCode == Keys.NumPad4))
                {
                    num = -5f;
                }
                else if ((e.KeyCode == Keys.W) || (e.KeyCode == Keys.NumPad8))
                {
                    num2 = -5f;
                }
                else if ((e.KeyCode == Keys.S) || (e.KeyCode == Keys.NumPad2))
                {
                    num2 = 5f;
                }
                else if (((e.KeyCode != Keys.E) && (e.KeyCode != Keys.NumPad9)) && ((e.KeyCode != Keys.Z) && (e.KeyCode != Keys.NumPad1)))
                {
                }
                if ((num != 0.0) || (num2 != 0.0))
                {
                    if (this.m_UpsideDown)
                    {
                        num = -num;
                    }
                    
                    Vector3 result = new Vector3();
              
                    float num3 = (((result.X * ((float) Math.Cos((double) this.m_CamRotation.X))) + (result.Z * ((float) Math.Sin((double) this.m_CamRotation.X)))) * ((float) Math.Cos((double) this.m_CamRotation.Y))) + (result.Y * ((float) Math.Sin((double) this.m_CamRotation.Y)));
                    num *= this.m_PixelFactorX * num3;
                    num2 *= -this.m_PixelFactorY * num3;
                    float num7 = (num * ((float) Math.Sin((double) this.m_CamRotation.X))) - ((num2 * ((float) Math.Sin((double) this.m_CamRotation.Y))) * ((float) Math.Cos((double) this.m_CamRotation.X)));
                    float num6 = num2 * ((float) Math.Cos((double) this.m_CamRotation.Y));
                    float num5 = (num * ((float) Math.Cos((double) this.m_CamRotation.X))) + ((num2 * ((float) Math.Sin((double) this.m_CamRotation.Y))) * ((float) Math.Sin((double) this.m_CamRotation.X)));
                 
                    flag = true;
                }
                if (flag)
                {
                    
                }
            }
        }

        private void glc3DView_Load(object sender, EventArgs e)
        {
            this.m_PickingFrameBuffer = new uint[9];
            this.m_Selection = uint.MaxValue;
            this.m_UnderCursor = uint.MaxValue;
            this.m_GLLoaded = true;
            GL.Viewport(0, 0, this.glc3DView.Width, this.glc3DView.Height);
            float aspect = (float) (((double) this.glc3DView.Width) / ((double) this.glc3DView.Height));
            GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Projection);
            GL.LoadIdentity();
            Matrix4 t = Matrix4.CreatePerspectiveFieldOfView(1.22173f, aspect, 0.01f, 1000f);
            GL.MultMatrix(ref t);
            GL.Enable(EnableCap.DepthTest);
            Vector2 vector2 = new Vector2(0f, 0.3926991f);
            this.m_CamRotation = vector2;
            Vector3 vector = new Vector3(5f, 5f, 5f);
            this.m_CamTarget = vector;
            this.m_CamDistance = 1f;
            this.UpdateCamera();
            this.m_PixelFactorX = (float) (((2.0 * ((float) Math.Tan(0.6108652381980153))) * aspect) / ((double) this.glc3DView.Width));
            this.m_PixelFactorY = (float) ((2.0 * ((float) Math.Tan(0.6108652381980153))) / ((double) this.glc3DView.Height));
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Enable(EnableCap.AlphaTest);
            GL.AlphaFunc(AlphaFunction.Greater, 0f);
            GL.Enable(EnableCap.Texture2D);
            this.BuildGeometry();
            this.tbcObjTypeTabs.TabPages.RemoveAt(2);
            this.btnAddObject.Visible = false;
            this.btnRemoveObject.Visible = false;
        }

        private void glc3DView_MouseDown(object sender, MouseEventArgs e)
        {
            
            if (this.m_MouseDown == 0)
            {
                if (((this.m_PickingFrameBuffer[1] != this.m_PickingFrameBuffer[4]) || (this.m_PickingFrameBuffer[3] != this.m_PickingFrameBuffer[4])) || ((this.m_PickingFrameBuffer[5] != this.m_PickingFrameBuffer[4]) || (this.m_PickingFrameBuffer[7] != this.m_PickingFrameBuffer[4])))
                {
                    this.m_UnderCursor = uint.MaxValue;
                }
                else
                {
                    uint num = this.m_PickingFrameBuffer[4];
                    uint index = num >> 0x1c;
                    if (index != 15)
                    {
                        
                        if (index != (this.m_Selection >> 0x1c))
                        {
                            switch (index)
                            {
                                case 0:
                                    this.tbcLeftPanel.SelectedIndex = 1;
                                    this.tbcObjTypeTabs.SelectedIndex = 0;
                                    break;

                                case 1:
                                    this.tbcLeftPanel.SelectedIndex = 1;
                                    this.tbcObjTypeTabs.SelectedIndex = 1;
                                    break;

                                case 2:
                                    this.tbcLeftPanel.SelectedIndex = 1;
                                    this.tbcObjTypeTabs.SelectedIndex = 2;
                                    break;
                            }
                        }
                        
                        
                       
                        this.tvObjectList.SelectedNode = this.tvObjectList.Nodes.Find(string.Format("{0:X8}", num), true)[0];
                        this.tvObjectList.SelectedNode.EnsureVisible();
                        this.m_Selection = num;
                    }
                    this.m_UnderCursor = num;
                }
                if (e.Button == MouseButtons.Left)
                {
                    this.m_MouseDown = 1;
                }
                else
                {
                    if (e.Button != MouseButtons.Right)
                    {
                        return;
                    }
                    this.m_MouseDown = 2;
                }
                Point location = e.Location;
                this.m_LastMouseClick = location;
                Point point = e.Location;
                this.m_LastMouseMove = point;
            }
        }

        private void glc3DView_MouseMove(object sender, MouseEventArgs e)
        {
           
            float num = e.X - this.m_LastMouseMove.X;
            float num2 = e.Y - this.m_LastMouseMove.Y;
            Point location = e.Location;
            this.m_MouseCoords = location;
            Point point = e.Location;
            this.m_LastMouseMove = point;
            if (this.m_MouseDown != 0)
            {
                if ((this.m_UnderCursor >> 0x1c) == 15)
                {
                    if (this.m_MouseDown == 2)
                    {
                        if (this.btnReverseRot.Checked)
                        {
                            num = -num;
                            num2 = -num2;
                        }
                        if (this.m_UpsideDown)
                        {
                            num = -num;
                        }
                        this.m_CamRotation.X -= (float) (num * 0.0020000000949949026);
                        this.m_CamRotation.Y -= (float) (num2 * 0.0020000000949949026);
                    
                    }
                    else if (this.m_MouseDown == 1)
                    {
                        num = (float) (num * 0.004999999888241291);
                        num2 = (float) (num2 * 0.004999999888241291);
                        this.m_CamTarget.X -= num * ((float) Math.Sin((double) this.m_CamRotation.X));
                        this.m_CamTarget.X -= (num2 * ((float) Math.Cos((double) this.m_CamRotation.X))) * ((float) Math.Sin((double) this.m_CamRotation.Y));
                        this.m_CamTarget.Y += num2 * ((float) Math.Cos((double) this.m_CamRotation.Y));
                        this.m_CamTarget.Z += num * ((float) Math.Cos((double) this.m_CamRotation.X));
                        this.m_CamTarget.Z -= (num2 * ((float) Math.Sin((double) this.m_CamRotation.X))) * ((float) Math.Sin((double) this.m_CamRotation.Y));
                    }
                    this.UpdateCamera();
                }
                else if (this.m_MouseDown == 2)
                {
                    if (this.m_UpsideDown)
                    {
                        num = -num;
                    }
                    
                }
                else if (this.m_MouseDown == 1)
                {
                    
                   
                    Vector3 result = new Vector3();
                   
                    float num4 = (((result.X * ((float) Math.Cos((double) this.m_CamRotation.X))) + (result.Z * ((float) Math.Sin((double) this.m_CamRotation.X)))) * ((float) Math.Cos((double) this.m_CamRotation.Y))) + (result.Y * ((float) Math.Sin((double) this.m_CamRotation.Y)));
                    num *= this.m_PixelFactorX * num4;
                    num2 *= -this.m_PixelFactorY * num4;
                    float num7 = (num * ((float) Math.Sin((double) this.m_CamRotation.X))) - ((num2 * ((float) Math.Sin((double) this.m_CamRotation.Y))) * ((float) Math.Cos((double) this.m_CamRotation.X)));
                    float num6 = num2 * ((float) Math.Cos((double) this.m_CamRotation.Y));
                    float num5 = (num * ((float) Math.Cos((double) this.m_CamRotation.X))) + ((num2 * ((float) Math.Sin((double) this.m_CamRotation.Y))) * ((float) Math.Sin((double) this.m_CamRotation.X)));
             
                }
            }
            else if (((this.m_PickingFrameBuffer[1] == this.m_PickingFrameBuffer[4]) && (this.m_PickingFrameBuffer[3] == this.m_PickingFrameBuffer[4])) && ((this.m_PickingFrameBuffer[5] == this.m_PickingFrameBuffer[4]) && (this.m_PickingFrameBuffer[7] == this.m_PickingFrameBuffer[4])))
            {
                uint num3 = this.m_PickingFrameBuffer[4];
                if ((num3 >> 0x1c) == 15)
                {
                    
                }
                else
                {
                    
                }
            }
            this.glc3DView.Refresh();
        }

        private void glc3DView_MouseUp(object sender, MouseEventArgs e)
        {
            if (this.m_MouseDown == 1)
            {
                if (e.Button != MouseButtons.Left)
                {
                    return;
                }
            }
            else if ((this.m_MouseDown != 2) || (e.Button != MouseButtons.Right))
            {
                return;
            }
            if ((((this.m_Selection >> 0x1c) != 15) && ((this.m_UnderCursor >> 0x1c) == 15)) && ((Math.Abs((int) (e.Location.X - this.m_LastMouseClick.X)) < 3) && (Math.Abs((int) (e.Location.Y - this.m_LastMouseClick.Y)) < 3)))
            {
                this.m_Selection = uint.MaxValue;
              
                this.tvObjectList.SelectedNode = null;
            }
            this.m_MouseDown = 0;
        }

        private void glc3DView_MouseWheel(object sender, MouseEventArgs e)
        {
            if ((this.m_MouseDown == 1) && ((this.m_Selection >> 0x1c) != 15))
            {
                float num = (float) -(((double) e.Delta) / 120.0);
                num = (float) (((float) Math.Pow((double) num, 3.0)) * 0.05000000074505806);
                
                float num4 = (float) ((num * (this.m_MouseCoords.X - (((double) this.glc3DView.Width) / 2.0))) * this.m_PixelFactorX);
                float num3 = (float) ((num * (this.m_MouseCoords.Y - (((double) this.glc3DView.Height) / 2.0))) * this.m_PixelFactorY);

            }
            else
            {
                float num2 = (float) -((((double) e.Delta) / 120.0) * 0.10000000149011612);
                this.m_CamTarget.X += (num2 * ((float) Math.Cos((double) this.m_CamRotation.X))) * ((float) Math.Cos((double) this.m_CamRotation.Y));
                this.m_CamTarget.Y += num2 * ((float) Math.Sin((double) this.m_CamRotation.Y));
                this.m_CamTarget.Z += (num2 * ((float) Math.Sin((double) this.m_CamRotation.X))) * ((float) Math.Cos((double) this.m_CamRotation.Y));
                this.UpdateCamera();
            }
            this.glc3DView.Refresh();
        }

        private void glc3DView_Paint(object sender, PaintEventArgs e)
        {
            if (this.m_GLLoaded)
            {
                this.glc3DView.Context.MakeCurrent(this.glc3DView.WindowInfo);
                this.Render3DMap();
                this.glc3DView.SwapBuffers();
            }
        }

        private void glc3DView_Resize(object sender, EventArgs e)
        {
            if (this.m_GLLoaded)
            {
                this.glc3DView.Context.MakeCurrent(this.glc3DView.WindowInfo);
                GL.Viewport(0, 0, this.glc3DView.Width, this.glc3DView.Height);
                float aspect = (float) (((double) this.glc3DView.Width) / ((double) this.glc3DView.Height));
                GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Projection);
                GL.LoadIdentity();
                Matrix4 t = Matrix4.CreatePerspectiveFieldOfView(1.22173f, aspect, 0.05f, 1000f);
                GL.MultMatrix(ref t);
                this.m_PixelFactorX = (float) (((2.0 * ((float) Math.Tan(0.6108652381980153))) * aspect) / ((double) this.glc3DView.Width));
                this.m_PixelFactorY = (float) ((2.0 * ((float) Math.Tan(0.6108652381980153))) / ((double) this.glc3DView.Height));
            }
        }

        private void InitializeComponent()
        {
            ToolStripItem[] toolStripItems = null;
            ComponentResourceManager manager = null;
            ToolStripItem[] itemArray2 = null;
            ToolStripItem[] itemArray3 = null;
            ToolStripLabel label = null;
            TreeNode[] nodes = null;
            ToolStripSeparator separator = null;
            ToolStripSeparator separator2 = null;
            TreeNode node = null;
            TreeNode node2 = null;
            ToolStripItem[] itemArray4 = null;
            ToolStripItem[] itemArray5 = null;
            this.components = new Container();
            manager = new ComponentResourceManager(typeof(EditorMainForm));
            node2 = new TreeNode("Common");
            node = new TreeNode("Layer blahblah");
            this.toolStrip1 = new ToolStrip();
            this.btnSaveLevel = new ToolStripButton();
            this.btnLevelSettings = new ToolStripButton();
            this.btnLayer0 = new ToolStripButton();
            this.btnLayer1 = new ToolStripButton();
            this.btnLayer2 = new ToolStripButton();
            this.btnLayer3 = new ToolStripButton();
            this.btnLayer4 = new ToolStripButton();
            this.btnLayer5 = new ToolStripButton();
            this.btnLayer6 = new ToolStripButton();
            this.btnLayer7 = new ToolStripButton();
            this.glc3DView = new GLControl();
            this.tvModelBlocks = new TreeView();
            this.ctm3DOptions = new ContextMenuStrip(this.components);
            this.btnDumpTexture = new ToolStripMenuItem();
            this.splitContainer1 = new SplitContainer();
            this.tbcLeftPanel = new TabControl();
            this.tbpModelBlox = new TabPage();
            this.tbpObjects = new TabPage();
            this.scObjPanelContainer = new SplitContainer();
            this.tbcObjTypeTabs = new TabControl();
            this.tbpObj0Panel = new TabPage();
            this.tvObjectList = new TreeView();
            this.tbpObj1Panel = new TabPage();
            this.tbpObj2Panel = new TabPage();
            this.tlpObjEditPanel = new TableLayoutPanel();
            this.toolStrip2 = new ToolStrip();
            this.btnAddObject = new ToolStripSplitButton();
            this.btnAddObj0 = new ToolStripMenuItem();
            this.btnAddObj1 = new ToolStripMenuItem();
            this.btnAddObj2 = new ToolStripMenuItem();
            this.btnAddObj3 = new ToolStripMenuItem();
            this.btnAddObj4 = new ToolStripMenuItem();
            this.btnAddObj5 = new ToolStripMenuItem();
            this.btnAddObj6 = new ToolStripMenuItem();
            this.btnAddObj7 = new ToolStripMenuItem();
            this.btnRemoveObject = new ToolStripButton();
            this.btnReverseRot = new ToolStripButton();
            this.sbrStatus = new StatusStrip();
            this.sblStatusLabel = new ToolStripStatusLabel();
            this.texexport = new SaveFileDialog();
            separator2 = new ToolStripSeparator();
            separator = new ToolStripSeparator();
            label = new ToolStripLabel();
            this.toolStrip1.SuspendLayout();
            this.ctm3DOptions.SuspendLayout();
            this.splitContainer1.Panel1.SuspendLayout();
            this.splitContainer1.Panel2.SuspendLayout();
            this.splitContainer1.SuspendLayout();
            this.tbcLeftPanel.SuspendLayout();
            this.tbpModelBlox.SuspendLayout();
            this.tbpObjects.SuspendLayout();
            this.scObjPanelContainer.Panel1.SuspendLayout();
            this.scObjPanelContainer.Panel2.SuspendLayout();
            this.scObjPanelContainer.SuspendLayout();
            this.tbcObjTypeTabs.SuspendLayout();
            this.tbpObj0Panel.SuspendLayout();
            this.toolStrip2.SuspendLayout();
            this.sbrStatus.SuspendLayout();
            base.SuspendLayout();
            separator2.Name = "toolStripSeparator1";
            Size size44 = new Size(6, 0x19);
            separator2.Size = size44;
            separator.Name = "toolStripSeparator2";
            Size size43 = new Size(6, 0x19);
            separator.Size = size43;
            label.Name = "toolStripLabel1";
            Size size42 = new Size(0x7d, 0x16);
            label.Size = size42;
            label.Text = "Show objects for stars:";
            toolStripItems = new ToolStripItem[] { this.btnSaveLevel, separator2, this.btnLevelSettings, separator, label, this.btnLayer0, this.btnLayer1, this.btnLayer2, this.btnLayer3, this.btnLayer4, this.btnLayer5, this.btnLayer6, this.btnLayer7 };
            this.toolStrip1.Items.AddRange(toolStripItems);
            Point point16 = new Point(0, 0);
            this.toolStrip1.Location = point16;
            this.toolStrip1.Name = "toolStrip1";
            Size size41 = new Size(0x3c3, 0x19);
            this.toolStrip1.Size = size41;
            this.toolStrip1.TabIndex = 0;
            this.toolStrip1.Text = "toolStrip1";
            this.btnSaveLevel.DisplayStyle = ToolStripItemDisplayStyle.Text;
            //this.btnSaveLevel.Image = (Image) manager.GetObject("btnSaveLevel.Image");
            Color magenta = Color.Magenta;
            this.btnSaveLevel.ImageTransparentColor = magenta;
            this.btnSaveLevel.Name = "btnSaveLevel";
            Size size40 = new Size(0x23, 0x16);
            this.btnSaveLevel.Size = size40;
            this.btnSaveLevel.Text = "Save";
            this.btnSaveLevel.ToolTipText = "don't forget to click\r\nme regularly if you\r\ndon't want to lose\r\nyour changes";
  
            this.btnLevelSettings.DisplayStyle = ToolStripItemDisplayStyle.Text;
           //this.btnLevelSettings.Image = (Image) manager.GetObject("btnLevelSettings.Image");
            Color color13 = Color.Magenta;
            this.btnLevelSettings.ImageTransparentColor = color13;
            this.btnLevelSettings.Name = "btnLevelSettings";
            Size size39 = new Size(0x52, 0x16);
            this.btnLevelSettings.Size = size39;
            this.btnLevelSettings.Text = "Level settings";
            this.btnLevelSettings.ToolTipText = "change the sky and all that";
     
            this.btnLayer0.CheckOnClick = true;
            this.btnLayer0.DisplayStyle = ToolStripItemDisplayStyle.Text;
          //  this.btnLayer0.Image = (Image) manager.GetObject("btnLayer0.Image");
            Color color12 = Color.Magenta;
            this.btnLayer0.ImageTransparentColor = color12;
            this.btnLayer0.Name = "btnLayer0";
            Size size38 = new Size(0x19, 0x16);
            this.btnLayer0.Size = size38;
            this.btnLayer0.Tag = "0";
            this.btnLayer0.Text = "All";
      
            this.btnLayer1.CheckOnClick = true;
            this.btnLayer1.DisplayStyle = ToolStripItemDisplayStyle.Text;
           // this.btnLayer1.Image = (Image) manager.GetObject("btnLayer1.Image");
            Color color11 = Color.Magenta;
            this.btnLayer1.ImageTransparentColor = color11;
            this.btnLayer1.Name = "btnLayer1";
            Size size37 = new Size(0x17, 0x16);
            this.btnLayer1.Size = size37;
            this.btnLayer1.Tag = "1";
            this.btnLayer1.Text = "1";
      
            this.btnLayer2.CheckOnClick = true;
            this.btnLayer2.DisplayStyle = ToolStripItemDisplayStyle.Text;
           // this.btnLayer2.Image = (Image) manager.GetObject("btnLayer2.Image");
            Color color10 = Color.Magenta;
            this.btnLayer2.ImageTransparentColor = color10;
            this.btnLayer2.Name = "btnLayer2";
            Size size36 = new Size(0x17, 0x16);
            this.btnLayer2.Size = size36;
            this.btnLayer2.Tag = "2";
            this.btnLayer2.Text = "2";
  
            this.btnLayer3.CheckOnClick = true;
            this.btnLayer3.DisplayStyle = ToolStripItemDisplayStyle.Text;
            //this.btnLayer3.Image = (Image) manager.GetObject("btnLayer3.Image");
            Color color9 = Color.Magenta;
            this.btnLayer3.ImageTransparentColor = color9;
            this.btnLayer3.Name = "btnLayer3";
            Size size35 = new Size(0x17, 0x16);
            this.btnLayer3.Size = size35;
            this.btnLayer3.Tag = "3";
            this.btnLayer3.Text = "3";
      
            this.btnLayer4.CheckOnClick = true;
            this.btnLayer4.DisplayStyle = ToolStripItemDisplayStyle.Text;
            //this.btnLayer4.Image = (Image) manager.GetObject("btnLayer4.Image");
            Color color8 = Color.Magenta;
            this.btnLayer4.ImageTransparentColor = color8;
            this.btnLayer4.Name = "btnLayer4";
            Size size34 = new Size(0x17, 0x16);
            this.btnLayer4.Size = size34;
            this.btnLayer4.Tag = "4";
            this.btnLayer4.Text = "4";
 
            this.btnLayer5.CheckOnClick = true;
            this.btnLayer5.DisplayStyle = ToolStripItemDisplayStyle.Text;
            //this.btnLayer5.Image = (Image) manager.GetObject("btnLayer5.Image");
            Color color7 = Color.Magenta;
            this.btnLayer5.ImageTransparentColor = color7;
            this.btnLayer5.Name = "btnLayer5";
            Size size33 = new Size(0x17, 0x16);
            this.btnLayer5.Size = size33;
            this.btnLayer5.Tag = "5";
            this.btnLayer5.Text = "5";
     
            this.btnLayer6.CheckOnClick = true;
            this.btnLayer6.DisplayStyle = ToolStripItemDisplayStyle.Text;
            //this.btnLayer6.Image = (Image) manager.GetObject("btnLayer6.Image");
            Color color6 = Color.Magenta;
            this.btnLayer6.ImageTransparentColor = color6;
            this.btnLayer6.Name = "btnLayer6";
            Size size32 = new Size(0x17, 0x16);
            this.btnLayer6.Size = size32;
            this.btnLayer6.Tag = "6";
            this.btnLayer6.Text = "6";
    
            this.btnLayer7.CheckOnClick = true;
            this.btnLayer7.DisplayStyle = ToolStripItemDisplayStyle.Text;
           // this.btnLayer7.Image = (Image) manager.GetObject("btnLayer7.Image");
            Color color5 = Color.Magenta;
            this.btnLayer7.ImageTransparentColor = color5;
            this.btnLayer7.Name = "btnLayer7";
            Size size31 = new Size(0x17, 0x16);
            this.btnLayer7.Size = size31;
            this.btnLayer7.Tag = "7";
            this.btnLayer7.Text = "7";
   
            this.glc3DView.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            Color black = Color.Black;
            this.glc3DView.BackColor = black;
            Point point15 = new Point(0, 0x1c);
            this.glc3DView.Location = point15;
            this.glc3DView.Name = "glc3DView";
            Size size30 = new Size(0x2cf, 0x217);
            this.glc3DView.Size = size30;
            this.glc3DView.TabIndex = 3;
            this.glc3DView.VSync = false;
            this.glc3DView.Load += new EventHandler(this.glc3DView_Load);
            this.glc3DView.MouseWheel += new MouseEventHandler(this.glc3DView_MouseWheel);
            this.glc3DView.Paint += new PaintEventHandler(this.glc3DView_Paint);
            this.glc3DView.MouseMove += new MouseEventHandler(this.glc3DView_MouseMove);
            this.glc3DView.MouseDown += new MouseEventHandler(this.glc3DView_MouseDown);
            this.glc3DView.Resize += new EventHandler(this.glc3DView_Resize);
            this.glc3DView.MouseUp += new MouseEventHandler(this.glc3DView_MouseUp);
            this.glc3DView.KeyDown += new KeyEventHandler(this.glc3DView_KeyDown);
            this.tvModelBlocks.CheckBoxes = true;
            this.tvModelBlocks.Dock = DockStyle.Fill;
            Point point14 = new Point(0, 0);
            this.tvModelBlocks.Location = point14;
            Padding padding10 = new Padding(0);
            this.tvModelBlocks.Margin = padding10;
            this.tvModelBlocks.Name = "tvModelBlocks";
            Size size29 = new Size(0xe8, 0x219);
            this.tvModelBlocks.Size = size29;
            this.tvModelBlocks.TabIndex = 5;
            this.tvModelBlocks.AfterCheck += new TreeViewEventHandler(this.tvModelBlocks_AfterCheck);
            this.tvModelBlocks.MouseClick += new MouseEventHandler(this.tvModelBlocks_MouseClick);
            itemArray5 = new ToolStripItem[] { this.btnDumpTexture };
            this.ctm3DOptions.Items.AddRange(itemArray5);
            this.ctm3DOptions.Name = "ctm3DOptions";
            Size size28 = new Size(0x93, 0x1a);
            this.ctm3DOptions.Size = size28;
            this.btnDumpTexture.Name = "btnDumpTexture";
            Size size27 = new Size(0x92, 0x16);
            this.btnDumpTexture.Size = size27;
            this.btnDumpTexture.Text = "Dump texture";
            this.btnDumpTexture.Click += new EventHandler(this.btnDumpTexture_Click);
            this.splitContainer1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.splitContainer1.FixedPanel = FixedPanel.Panel1;
            Point point13 = new Point(0, 0x19);
            this.splitContainer1.Location = point13;
            Padding padding9 = new Padding(0);
            this.splitContainer1.Margin = padding9;
            this.splitContainer1.Name = "splitContainer1";
            this.splitContainer1.Panel1.Controls.Add(this.tbcLeftPanel);
            this.splitContainer1.Panel2.Controls.Add(this.toolStrip2);
            this.splitContainer1.Panel2.Controls.Add(this.glc3DView);
            Size size26 = new Size(0x3c3, 0x233);
            this.splitContainer1.Size = size26;
            this.splitContainer1.SplitterDistance = 240;
            this.splitContainer1.TabIndex = 6;
            this.tbcLeftPanel.Alignment = TabAlignment.Bottom;
            this.tbcLeftPanel.Controls.Add(this.tbpModelBlox);
            this.tbcLeftPanel.Controls.Add(this.tbpObjects);
            this.tbcLeftPanel.Dock = DockStyle.Fill;
            Point point12 = new Point(0, 0);
            this.tbcLeftPanel.Location = point12;
            Padding padding8 = new Padding(0);
            this.tbcLeftPanel.Margin = padding8;
            this.tbcLeftPanel.Multiline = true;
            this.tbcLeftPanel.Name = "tbcLeftPanel";
            this.tbcLeftPanel.SelectedIndex = 0;
            Size size25 = new Size(240, 0x233);
            this.tbcLeftPanel.Size = size25;
            this.tbcLeftPanel.TabIndex = 0;
            this.tbcLeftPanel.SelectedIndexChanged += new EventHandler(this.tbcLeftPanel_SelectedIndexChanged);
            this.tbpModelBlox.Controls.Add(this.tvModelBlocks);
            Point point11 = new Point(4, 4);
            this.tbpModelBlox.Location = point11;
            Padding padding7 = new Padding(0);
            this.tbpModelBlox.Margin = padding7;
            this.tbpModelBlox.Name = "tbpModelBlox";
            Size size24 = new Size(0xe8, 0x219);
            this.tbpModelBlox.Size = size24;
            this.tbpModelBlox.TabIndex = 0;
            this.tbpModelBlox.Text = "3D model";
            this.tbpModelBlox.UseVisualStyleBackColor = true;
            this.tbpObjects.Controls.Add(this.scObjPanelContainer);
            Point point10 = new Point(4, 4);
            this.tbpObjects.Location = point10;
            Padding padding6 = new Padding(0);
            this.tbpObjects.Margin = padding6;
            this.tbpObjects.Name = "tbpObjects";
            Size size23 = new Size(0xe8, 0x219);
            this.tbpObjects.Size = size23;
            this.tbpObjects.TabIndex = 1;
            this.tbpObjects.Text = "Objects";
            this.tbpObjects.UseVisualStyleBackColor = true;
            this.scObjPanelContainer.Dock = DockStyle.Fill;
            this.scObjPanelContainer.FixedPanel = FixedPanel.Panel2;
            Point point9 = new Point(0, 0);
            this.scObjPanelContainer.Location = point9;
            Padding padding5 = new Padding(0);
            this.scObjPanelContainer.Margin = padding5;
            this.scObjPanelContainer.Name = "scObjPanelContainer";
            this.scObjPanelContainer.Orientation = Orientation.Horizontal;
            this.scObjPanelContainer.Panel1.Controls.Add(this.tbcObjTypeTabs);
            this.scObjPanelContainer.Panel2.Controls.Add(this.tlpObjEditPanel);
            Size size22 = new Size(0xe8, 0x219);
            this.scObjPanelContainer.Size = size22;
            this.scObjPanelContainer.SplitterDistance = 0xf2;
            this.scObjPanelContainer.TabIndex = 3;
            this.tbcObjTypeTabs.Controls.Add(this.tbpObj0Panel);
            this.tbcObjTypeTabs.Controls.Add(this.tbpObj1Panel);
            this.tbcObjTypeTabs.Controls.Add(this.tbpObj2Panel);
            this.tbcObjTypeTabs.Dock = DockStyle.Fill;
            Point point8 = new Point(0, 0);
            this.tbcObjTypeTabs.Location = point8;
            Padding padding4 = new Padding(0);
            this.tbcObjTypeTabs.Margin = padding4;
            this.tbcObjTypeTabs.Name = "tbcObjTypeTabs";
            this.tbcObjTypeTabs.SelectedIndex = 0;
            Size size21 = new Size(0xe8, 0xf2);
            this.tbcObjTypeTabs.Size = size21;
            this.tbcObjTypeTabs.TabIndex = 2;
            this.tbcObjTypeTabs.SelectedIndexChanged += new EventHandler(this.tbcObjTypeTabs_SelectedIndexChanged);
            this.tbpObj0Panel.Controls.Add(this.tvObjectList);
            Point point7 = new Point(4, 0x16);
            this.tbpObj0Panel.Location = point7;
            Padding padding3 = new Padding(0);
            this.tbpObj0Panel.Margin = padding3;
            this.tbpObj0Panel.Name = "tbpObj0Panel";
            Size size20 = new Size(0xe0, 0xd8);
            this.tbpObj0Panel.Size = size20;
            this.tbpObj0Panel.TabIndex = 0;
            this.tbpObj0Panel.Text = "Standard";
            this.tbpObj0Panel.UseVisualStyleBackColor = true;
            this.tvObjectList.Dock = DockStyle.Fill;
            this.tvObjectList.DrawMode = TreeViewDrawMode.OwnerDrawText;
            this.tvObjectList.HideSelection = false;
            Point point6 = new Point(0, 0);
            this.tvObjectList.Location = point6;
            Padding padding2 = new Padding(0);
            this.tvObjectList.Margin = padding2;
            this.tvObjectList.Name = "tvObjectList";
            node2.Name = "Noeud0";
            node2.Text = "Common";
            node.Name = "Noeud1";
            node.Text = "Layer blahblah";
            nodes = new TreeNode[] { node2, node };
            this.tvObjectList.Nodes.AddRange(nodes);
            this.tvObjectList.ShowLines = false;
            Size size19 = new Size(0xe0, 0xd8);
            this.tvObjectList.Size = size19;
            this.tvObjectList.TabIndex = 0;
            this.tvObjectList.DrawNode += new DrawTreeNodeEventHandler(this.tvObjectList_DrawNode);
       
            Point point5 = new Point(4, 0x16);
            this.tbpObj1Panel.Location = point5;
            Padding padding = new Padding(0);
            this.tbpObj1Panel.Margin = padding;
            this.tbpObj1Panel.Name = "tbpObj1Panel";
            Size size18 = new Size(0xe0, 0xd8);
            this.tbpObj1Panel.Size = size18;
            this.tbpObj1Panel.TabIndex = 1;
            this.tbpObj1Panel.Text = "Simple";
            this.tbpObj1Panel.UseVisualStyleBackColor = true;
            Point point4 = new Point(4, 0x16);
            this.tbpObj2Panel.Location = point4;
            this.tbpObj2Panel.Name = "tbpObj2Panel";
            Size size17 = new Size(0xe0, 0xd8);
            this.tbpObj2Panel.Size = size17;
            this.tbpObj2Panel.TabIndex = 2;
            this.tbpObj2Panel.Text = "Extra";
            this.tbpObj2Panel.UseVisualStyleBackColor = true;
            this.tlpObjEditPanel.ColumnCount = 2;
            this.tlpObjEditPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 100f));
            this.tlpObjEditPanel.ColumnStyles.Add(new ColumnStyle());
            this.tlpObjEditPanel.Dock = DockStyle.Fill;
            Point point3 = new Point(0, 0);
            this.tlpObjEditPanel.Location = point3;
            this.tlpObjEditPanel.Name = "tlpObjEditPanel";
            this.tlpObjEditPanel.RowCount = 9;
            this.tlpObjEditPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100f));
            this.tlpObjEditPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 235f));
            this.tlpObjEditPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 20f));
            this.tlpObjEditPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 20f));
            this.tlpObjEditPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 20f));
            this.tlpObjEditPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 20f));
            this.tlpObjEditPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 20f));
            this.tlpObjEditPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 20f));
            this.tlpObjEditPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 20f));
            Size size16 = new Size(0xe8, 0x123);
            this.tlpObjEditPanel.Size = size16;
            this.tlpObjEditPanel.TabIndex = 0;
            itemArray3 = new ToolStripItem[] { this.btnAddObject, this.btnRemoveObject, this.btnReverseRot };
            this.toolStrip2.Items.AddRange(itemArray3);
            Point point2 = new Point(0, 0);
            this.toolStrip2.Location = point2;
            this.toolStrip2.Name = "toolStrip2";
            Size size15 = new Size(0x2cf, 0x19);
            this.toolStrip2.Size = size15;
            this.toolStrip2.TabIndex = 4;
            this.toolStrip2.Text = "toolStrip2";
            this.btnAddObject.DisplayStyle = ToolStripItemDisplayStyle.Text;
            itemArray2 = new ToolStripItem[] { this.btnAddObj0, this.btnAddObj1, this.btnAddObj2, this.btnAddObj3, this.btnAddObj4, this.btnAddObj5, this.btnAddObj6, this.btnAddObj7 };
            this.btnAddObject.DropDownItems.AddRange(itemArray2);
            this.btnAddObject.Enabled = false;
            //this.btnAddObject.Image = (Image) manager.GetObject("btnAddObject.Image");
            Color color3 = Color.Magenta;
            this.btnAddObject.ImageTransparentColor = color3;
            this.btnAddObject.Name = "btnAddObject";
            Size size14 = new Size(0x51, 0x16);
            this.btnAddObject.Size = size14;
            this.btnAddObject.Text = "Add object";
            this.btnAddObject.ToolTipText = "this level lacks Goombas, clearly";

            this.btnAddObj0.Name = "btnAddObj0";
            Size size13 = new Size(0x73, 0x16);
            this.btnAddObj0.Size = size13;
            this.btnAddObj0.Tag = "0";
            this.btnAddObj0.Text = "All stars";

            this.btnAddObj1.Name = "btnAddObj1";
            Size size12 = new Size(0x73, 0x16);
            this.btnAddObj1.Size = size12;
            this.btnAddObj1.Tag = "1";
            this.btnAddObj1.Text = "Star 1";
       
            this.btnAddObj2.Name = "btnAddObj2";
            Size size11 = new Size(0x73, 0x16);
            this.btnAddObj2.Size = size11;
            this.btnAddObj2.Tag = "2";
            this.btnAddObj2.Text = "Star 2";
       
            this.btnAddObj3.Name = "btnAddObj3";
            Size size10 = new Size(0x73, 0x16);
            this.btnAddObj3.Size = size10;
            this.btnAddObj3.Tag = "3";
            this.btnAddObj3.Text = "Star 3";
        
            this.btnAddObj4.Name = "btnAddObj4";
            Size size9 = new Size(0x73, 0x16);
            this.btnAddObj4.Size = size9;
            this.btnAddObj4.Tag = "4";
            this.btnAddObj4.Text = "Star 4";
       
            this.btnAddObj5.Name = "btnAddObj5";
            Size size8 = new Size(0x73, 0x16);
            this.btnAddObj5.Size = size8;
            this.btnAddObj5.Tag = "5";
            this.btnAddObj5.Text = "Star 5";
 
            this.btnAddObj6.Name = "btnAddObj6";
            Size size7 = new Size(0x73, 0x16);
            this.btnAddObj6.Size = size7;
            this.btnAddObj6.Tag = "6";
            this.btnAddObj6.Text = "Star 6";
          
            this.btnAddObj7.Name = "btnAddObj7";
            Size size6 = new Size(0x73, 0x16);
            this.btnAddObj7.Size = size6;
            this.btnAddObj7.Tag = "7";
            this.btnAddObj7.Text = "Star 7";
  
            this.btnRemoveObject.DisplayStyle = ToolStripItemDisplayStyle.Text;
            this.btnRemoveObject.Enabled = false;
           // this.btnRemoveObject.Image = (Image) manager.GetObject("btnRemoveObject.Image");
            Color color2 = Color.Magenta;
            this.btnRemoveObject.ImageTransparentColor = color2;
            this.btnRemoveObject.Name = "btnRemoveObject";
            Size size5 = new Size(100, 0x16);
            this.btnRemoveObject.Size = size5;
            this.btnRemoveObject.Text = "Remove selected";
            this.btnReverseRot.CheckOnClick = true;
            this.btnReverseRot.DisplayStyle = ToolStripItemDisplayStyle.Text;
            //this.btnReverseRot.Image = (Image) manager.GetObject("btnReverseRot.Image");
            Color color = Color.Magenta;
            this.btnReverseRot.ImageTransparentColor = color;
            this.btnReverseRot.Name = "btnReverseRot";
            Size size4 = new Size(0x60, 0x16);
            this.btnReverseRot.Size = size4;
            this.btnReverseRot.Text = "Reverse rotation";
            itemArray4 = new ToolStripItem[] { this.sblStatusLabel };
            this.sbrStatus.Items.AddRange(itemArray4);
            Point point = new Point(0, 0x24c);
            this.sbrStatus.Location = point;
            this.sbrStatus.Name = "sbrStatus";
            Size size3 = new Size(0x3c3, 0x16);
            this.sbrStatus.Size = size3;
            this.sbrStatus.TabIndex = 7;
            this.sbrStatus.Text = "statusStrip1";
            this.sblStatusLabel.Name = "sblStatusLabel";
            Size size2 = new Size(0x54, 0x11);
            this.sblStatusLabel.Size = size2;
            this.sblStatusLabel.Text = "junk goes here";
            this.texexport.DefaultExt = "png";
            this.texexport.Filter = "PNG image|*.png";
            this.texexport.RestoreDirectory = true;
            this.texexport.Title = "Save texture to...";
            SizeF ef = new SizeF(6f, 13f);
            base.AutoScaleDimensions = ef;
            base.AutoScaleMode = AutoScaleMode.Font;
            Size size = new Size(0x3c3, 610);
            base.ClientSize = size;
            base.Controls.Add(this.sbrStatus);
            base.Controls.Add(this.splitContainer1);
            base.Controls.Add(this.toolStrip1);
            //base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.Name = "EditorMainForm";
            this.Text = "EditorMainForm";
            base.Paint += new PaintEventHandler(this.EditorMainForm_Paint);
            base.FormClosed += new FormClosedEventHandler(this.EditorMainForm_FormClosed);
            this.toolStrip1.ResumeLayout(false);
            this.toolStrip1.PerformLayout();
            this.ctm3DOptions.ResumeLayout(false);
            this.splitContainer1.Panel1.ResumeLayout(false);
            this.splitContainer1.Panel2.ResumeLayout(false);
            this.splitContainer1.Panel2.PerformLayout();
            this.splitContainer1.ResumeLayout(false);
            this.tbcLeftPanel.ResumeLayout(false);
            this.tbpModelBlox.ResumeLayout(false);
            this.tbpObjects.ResumeLayout(false);
            this.scObjPanelContainer.Panel1.ResumeLayout(false);
            this.scObjPanelContainer.Panel2.ResumeLayout(false);
            this.scObjPanelContainer.ResumeLayout(false);
            this.tbcObjTypeTabs.ResumeLayout(false);
            this.tbpObj0Panel.ResumeLayout(false);
            this.toolStrip2.ResumeLayout(false);
            this.toolStrip2.PerformLayout();
            this.sbrStatus.ResumeLayout(false);
            this.sbrStatus.PerformLayout();
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private unsafe void LoadLevelData()
        {
            
                this.m_SkyboxModel = null;
            
           
            this.m_LevelModel = new CBMD(new CNitroFile(bmd_2, 0));
            this.m_CSCache = new CClientStateCache();
        }

        private void objParamChanged(object sender, EventArgs e)
        {
            int index = this.tlpObjEditPanel.Controls.IndexOf((Control) sender);
            
            this.glc3DView.Refresh();
        }

       

        private void Render3DMap()
        {
            
            GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.MultMatrix(ref this.m_CamMatrix);
            GL.ClearColor(1f, 1f, 1f, 1f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.StencilBufferBit | ClearBufferMask.DepthBufferBit);
            GL.Disable(EnableCap.AlphaTest);
            GL.Disable(EnableCap.Blend);
            GL.Disable(EnableCap.Dither);
            GL.Disable(EnableCap.LineSmooth);
            GL.Disable(EnableCap.PolygonSmooth);
            GL.BindTexture(TextureTarget.Texture2D, 0);
            List<IGLGeometry>.Enumerator enumerator7 = this.m_OLevelGeometry.GetEnumerator();
            while (true)
            {
                if (!enumerator7.MoveNext())
                {
                    break;
                }
                enumerator7.Current.RenderForPicking();
            }
           
            GL.Flush();
            GL.ReadPixels<uint>(this.m_MouseCoords.X - 1, (this.glc3DView.Height - this.m_MouseCoords.Y) + 1, 3, 3, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, this.m_PickingFrameBuffer);
            GL.ClearColor(0f, 0f, 0.125f, 1f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.StencilBufferBit | ClearBufferMask.DepthBufferBit);
            GL.Enable(EnableCap.AlphaTest);
            GL.Enable(EnableCap.Blend);
            GL.Enable(EnableCap.Dither);
            GL.LoadIdentity();
            GL.MultMatrix(ref this.m_SkyboxMatrix);
            List<IGLGeometry>.Enumerator enumerator5 = this.m_OSkyboxGeometry.GetEnumerator();
            while (true)
            {
                if (!enumerator5.MoveNext())
                {
                    break;
                }
                enumerator5.Current.RenderActually();
            }
            GL.LoadIdentity();
            GL.MultMatrix(ref this.m_CamMatrix);
            List<IGLGeometry>.Enumerator enumerator4 = this.m_OLevelGeometry.GetEnumerator();
            while (true)
            {
                if (!enumerator4.MoveNext())
                {
                    break;
                }
                enumerator4.Current.RenderActually();
            }
            
            GL.LoadIdentity();
            GL.MultMatrix(ref this.m_SkyboxMatrix);
            List<IGLGeometry>.Enumerator enumerator2 = this.m_TSkyboxGeometry.GetEnumerator();
            while (true)
            {
                if (!enumerator2.MoveNext())
                {
                    break;
                }
                enumerator2.Current.RenderActually();
            }
            GL.LoadIdentity();
            GL.MultMatrix(ref this.m_CamMatrix);
            List<IGLGeometry>.Enumerator enumerator = this.m_TLevelGeometry.GetEnumerator();
            while (true)
            {
                if (!enumerator.MoveNext())
                {
                    break;
                }
                enumerator.Current.RenderActually();
            }
        }

      

        private void tbcLeftPanel_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.tbcObjTypeTabs.SelectedIndex = 0;
        }

        private void tbcObjTypeTabs_SelectedIndexChanged(object sender, EventArgs e)
        {
            int type = -1;
            if (this.tbcLeftPanel.SelectedIndex == 1)
            {
                switch (this.tbcObjTypeTabs.SelectedIndex)
                {
                    case 0:
                        type = 0;
                        break;

                    case 1:
                        type = 1;
                        break;

                    case 2:
                        type = 2;
                        break;
                }
                this.m_CurObjType = type;
                
                this.tvObjectList.Parent = this.tbcObjTypeTabs.SelectedTab;
            }
        }

        private void tvModelBlocks_AfterCheck(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Level == 0)
            {
                foreach (TreeNode node in e.Node.Nodes)
                {
                    byte num2;
                    if (e.Node.Checked && node.Checked)
                    {
                        num2 = 1;
                    }
                    else
                    {
                        num2 = 0;
                    }
                    ((IGLGeometry) node.Tag).Toggle(Convert.ToBoolean(num2));
                }
            }
            else if (e.Node.Level == 1)
            {
                byte num;
                if (e.Node.Checked && e.Node.Parent.Checked)
                {
                    num = 1;
                }
                else
                {
                    num = 0;
                }
                ((IGLGeometry) e.Node.Tag).Toggle(Convert.ToBoolean(num));
            }
            this.glc3DView.Refresh();
        }

        private void tvModelBlocks_MouseClick(object sender, MouseEventArgs e)
        {
            TreeViewHitTestInfo info = null;
            if (e.Button == MouseButtons.Right)
            {
                Point location = e.Location;
                info = this.tvModelBlocks.HitTest(location);
                this.tvModelBlocks.SelectedNode = info.Node;
                if ((info.Node != null) && (info.Node.Level == 1))
                {
                    Point position = e.Location;
                    this.ctm3DOptions.Show(this.tvModelBlocks, position);
                }
            }
        }

       

        private void tvObjectList_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            Font nodeFont = null;
            Color highlightText = new Color();
            Color highlight = new Color();
            nodeFont = e.Node.NodeFont;
            if (nodeFont == null)
            {
                nodeFont = this.tvObjectList.Font;
            }
            if ((e.State & (TreeNodeStates.Focused | TreeNodeStates.Selected)) != 0)
            {
                highlightText = SystemColors.HighlightText;
                highlight = SystemColors.Highlight;
            }
            else
            {
                highlightText = SystemColors.WindowText;
                highlight = SystemColors.Window;
            }
            Rectangle bounds = e.Bounds;
            e.Graphics.FillRectangle(new SolidBrush(highlight), bounds);
            Rectangle rectangle3 = e.Bounds;
            Rectangle rectangle2 = e.Bounds;
            e.Graphics.DrawString(e.Node.Text, nodeFont, new SolidBrush(highlightText), (float) rectangle2.X, (float) (rectangle3.Y + 1));
        }

        private void UpdateCamera()
        {
            Vector3 up = new Vector3();
            if (((float) Math.Cos((double) this.m_CamRotation.Y)) < 0.0)
            {
                this.m_UpsideDown = true;
                Vector3 vector5 = new Vector3(0f, -1f, 0f);
                up = vector5;
            }
            else
            {
                this.m_UpsideDown = false;
                Vector3 vector4 = new Vector3(0f, 1f, 0f);
                up = vector4;
            }
            this.m_CamPosition.X = (this.m_CamDistance * ((float) Math.Cos((double) this.m_CamRotation.X))) * ((float) Math.Cos((double) this.m_CamRotation.Y));
            this.m_CamPosition.Y = this.m_CamDistance * ((float) Math.Sin((double) this.m_CamRotation.Y));
            this.m_CamPosition.Z = (this.m_CamDistance * ((float) Math.Sin((double) this.m_CamRotation.X))) * ((float) Math.Cos((double) this.m_CamRotation.Y));
            Vector3 target = new Vector3();
            target.X = -((float) Math.Cos((double) this.m_CamRotation.X)) * ((float) Math.Cos((double) this.m_CamRotation.Y));
            target.Y = -((float) Math.Sin((double) this.m_CamRotation.Y));
            target.Z = -((float) Math.Sin((double) this.m_CamRotation.X)) * ((float) Math.Cos((double) this.m_CamRotation.Y));
            Vector3.Add(ref this.m_CamPosition, ref this.m_CamTarget, out this.m_CamPosition);
            Matrix4 matrix2 = Matrix4.LookAt(this.m_CamPosition, this.m_CamTarget, up);
            this.m_CamMatrix = matrix2;
            Vector3 eye = new Vector3(0f, 0f, 0f);
            Matrix4 matrix = Matrix4.LookAt(eye, target, up);
            this.m_SkyboxMatrix = matrix;
        }

        public void UpdateStuff()
        {
            
        }
    }
}

